25. Demo 5: Context and Templating
Templating With Context Variables - Demo 5
Correction: At timestamp 0.05 in the video above, the ending square bracket is missing. It should be python
print(f"Hello {kwargs['execution_date']}")
Runtime Variables
Airflow leverages templating to allow users to “fill in the blank” with important runtime variables for tasks.
from airflow import DAG
from airflow.operators.python_operator import PythonOperator
def hello_date(*args, **kwargs):
print(f“Hello {kwargs[‘execution_date’]}”)
divvy_dag = DAG(...)
task = PythonOperator(
task_id=’hello_date’,
python_callable=hello_date,
provide_context=True,
dag=divvy_dag)